const CryptoJS = require("crypto-js")

function md5(input) {
    return CryptoJS.MD5(input).toString()
}


function Base64() {
    // ... （之前的编码方法）

    this.decode = function (input) {
        var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
        var output = "";
        var chr1, chr2, chr3;
        var enc1, enc2, enc3, enc4;
        var i = 0;

        input = input.replace(/[^A-Za-z0-9+/=]/g, "");

        while (i < input.length) {
            enc1 = keyStr.indexOf(input.charAt(i++));
            enc2 = keyStr.indexOf(input.charAt(i++));
            enc3 = keyStr.indexOf(input.charAt(i++));
            enc4 = keyStr.indexOf(input.charAt(i++));

            chr1 = (enc1 << 2) | (enc2 >> 4);
            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
            chr3 = ((enc3 & 3) << 6) | enc4;

            output = output + String.fromCharCode(chr1);

            if (enc3 !== 64) {
                output = output + String.fromCharCode(chr2);
            }
            if (enc4 !== 64) {
                output = output + String.fromCharCode(chr3);
            }
        }

        return output;
    };
}


var AES = {
  decrypt: function(text, key, iv) {
    var secretkey = md5(key).substr(16, 16);
    var secretiv = md5(iv).substr(0, 16);
    secretkey = CryptoJS.enc.Utf8.parse(secretkey);
    secretiv = CryptoJS.enc.Utf8.parse(secretiv);
    var result = CryptoJS.AES.decrypt(text, secretkey, {
      iv: secretiv,
      mode: CryptoJS.mode.CBC,
      padding: CryptoJS.pad.Pkcs7
    });
    return result.toString(CryptoJS.enc.Utf8);
  }
}
var DES = {
 decrypt: function(text, key, iv){
    var secretkey = md5(key).substr(0, 16);
    var secretiv = md5(iv).substr(24, 8);
    secretkey = CryptoJS.enc.Utf8.parse(secretkey);
    secretiv = CryptoJS.enc.Utf8.parse(secretiv);
    var result = CryptoJS.DES.decrypt(text, secretkey, {
      iv: secretiv,
      mode: CryptoJS.mode.CBC,
      padding: CryptoJS.pad.Pkcs7
    });
    return result.toString(CryptoJS.enc.Utf8);
  }
};

var BASE64 = {
    decrypt: function(text) {
        var b = new Base64();
        return b.decode(text);
    }
}







function deIZLF7oahc0DLiXbqt(data) {
    data = AES.decrypt(data, "aPnyDR5Ca6FMIfdw", "bNpeyqJl34VlZ7ng");
    data = DES.decrypt(data, "hIFclTxH0JalYZiu", "xMFHANC8X1TunaGs");
    data = BASE64.decrypt(data);
    return data;
}
